<!--
 * @Descripttion:
 * @version: 1.0
 * @Author: Teemor
 * @Date: 2024-03-15 10:40:28
-->
<template>
  <uv-popup ref="openRef" mode="bottom" closeable round="24rpx">
    <view class="popupBox">
      <view class="top">筛选</view>
      <view class="mainBox">
        <view class="title">通讯状态 </view>
        <view class="list">
          <view
            class="button"
            :class="status.status === 1 ? 'active' : ''"
            @click="change('status', 1)"
            >在线</view
          >
          <view
            class="button"
            :class="status.status === 2 ? 'active' : ''"
            @click="change('status', 2)"
            >离线</view
          >
        </view>
        <view class="title">通讯状态</view>
        <view class="list">
          <view
            class="button"
            :class="status.status2 === 1 ? 'active' : ''"
            @click="change('status2', 1)"
            >运行</view
          >
          <view
            class="button"
            :class="status.status2 === 2 ? 'active' : ''"
            @click="change('status2', 2)"
            >停机</view
          >
          <view
            class="button"
            :class="status.status2 === 3 ? 'active' : ''"
            @click="change('status2', 3)"
            >待机</view
          >
          <view
            class="button"
            :class="status.status2 === 4 ? 'active' : ''"
            @click="change('status2', 4)"
            >故障</view
          >
          <view
            class="button"
            :class="status.status2 === 5 ? 'active' : ''"
            @click="change('status2', 5)"
            >待安装</view
          >
        </view>
      </view>
      <view class="bottom flex">
        <view class="flex-1 mr-4">
          <uv-button
            plain
            hairline
            shape="circle"
            text="重置"
            @click="
              () => {
                status.status = 1
                status.status2 = 1
              }
            "
          ></uv-button>
        </view>
        <view class="flex-1 mr-4">
          <uv-button
            type="primary"
            color=" linear-gradient(-33deg, #226CFF, #329AFB);"
            shape="circle"
            text="确定"
            @click="sub"
          ></uv-button>
        </view>
      </view>
    </view>
  </uv-popup>
</template>

<script setup>
const emit = defineEmits(['change'])
const openRef = ref()
const status = reactive({
  status: 1,
  status2: 1,
})
const sub = (e) => {
  emit('change', status)
  openRef.value.close()
}
const change = (e, n) => {
  status[e] = n
}
const open = () => {
  openRef.value.open()
}
defineExpose({
  open,
})
</script>

<style lang="scss" scoped>
.popupBox {
  .top {
    font-size: 32rpx;
    line-height: 100rpx;
    color: #354970;
    text-align: center;
    border: 1px solid #d7d7d7;
  }

  .mainBox {
    padding: 40rpx 46rpx;

    .title {
      display: flex;
      align-items: center;
      padding-bottom: 16rpx;
      font-size: 30rpx;
      color: #354970;

      &::before {
        box-sizing: border-box;
        display: block;
        width: 20rpx;
        height: 20rpx;
        margin-right: 10rpx;
        content: '';
        border: 6rpx solid #2473fe;
        border-radius: 20rpx;
      }
    }

    .list {
      display: flex;
      flex-wrap: wrap;
      padding-bottom: 60rpx;

      .button {
        padding: 0 66rpx;
        margin: 20rpx 20rpx 0 0;
        font-size: 28rpx;
        line-height: 72rpx;
        color: #354970;
        background: #fff;
        border: 2rpx solid #e7edfd;
        border-radius: 50rpx;

        &.active {
          color: #2472fe;
          background: #f2f7fe;
          border-color: #2472fe;
        }
      }
    }
  }

  .bottom {
    display: flex;
    justify-content: center;
    padding: 20rpx 10rpx 20rpx 40rpx;
    border-top: 1px solid #d7d7d7;

    :deep(.uv-button-wrapper) {
      flex: 1;
    }
  }
}
</style>
